#!usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author: Beyondzy
@file: 请求对象定制.py
@time: 2022/01/17
@desc:
"""
#将ua放到字典中
import urllib.request

header = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
}
url = 'https://www.baidu.com/'
request = urllib.request.Request(url=url,headers=header)
reponse = urllib.request.urlopen(request)
content = reponse.read().decode('utf-8')
print(content)